package cn.gjxblog.modules.sys.service.impl;

import cn.gjxblog.common.model.PageInfo;
import cn.gjxblog.common.model.PageRequest;
import cn.gjxblog.common.utils.mybaitsplus.ConditionJointUtils;
import cn.gjxblog.modules.sys.dao.SysUserDao;
import cn.gjxblog.modules.sys.entity.SysUserEntity;
import cn.gjxblog.modules.sys.model.vo.UserListRequest;
import cn.gjxblog.modules.sys.service.SysUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;


@Service("sysUserService")
public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {


    @Override
    public PageInfo<SysUserEntity> searchList(PageRequest request) {
        UserListRequest request1 = (UserListRequest) request;

        QueryWrapper<SysUserEntity> ew = new QueryWrapper<>();

        //拼接条件
        ConditionJointUtils.eqJoinWhenNotBlank(request1.getName(), "username", ew);


        IPage<SysUserEntity> page = this.page(new Page<>(request.getPageNum(), request.getPageSize()),ew);
        return new PageInfo<>(page);
    }
}